package com.consumer.newMigrate;


import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.consumer.config.URLConfig;
import com.consumer.entity.TProject;
import com.consumer.service.impl.MigrationService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;

@Resource
@RestController("new")
public class NewDemandMigrateController {


    @Resource
    MigrationService migrationService;

    //迁移项目
    public void migrateProject(){
        HashMap<String, Object> paramMap2 = new HashMap<>();
        String projects = HttpUtil.post(URLConfig.CONSUMER_URL + "queryAllProject", paramMap2);
        List<TProject> projectList = JSON.parseArray(projects, TProject.class);
        BlockingQueue<String> queue = projectList.stream().filter(Objects::nonNull).map(TProject::getProjectId).collect(Collectors.toCollection(LinkedBlockingQueue::new));

        for (String s : queue) {
            migrationService.migrateDemand(s);
        }


    }


    //迁移产品


}
